package com.wangsd.web.coupon.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wangsd.common.basicbean.Result;
import com.wangsd.web.coupon.entity.FileManagement;
import com.wangsd.web.coupon.service.FileManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author generator
 * @since 2019-09-19
 */
@Api(value = "fileManagement", tags = "文件管理")
@RestController
@RequestMapping("/coupon/fileManagement")
public class FileManagementController {
    @Autowired
    FileManagementService fileManagementService;

    @ApiOperation(value = "删除文件", notes = "删除文件", httpMethod = "GET", response = Result.class)
    @GetMapping("/delete/{uid}")
    public Result delete(@ApiParam(value = "文件uid", required = true) @PathVariable String uid) {
        boolean b = fileManagementService.remove(new QueryWrapper<FileManagement>().eq("uid",uid));
        return Result.success(b);

    }

    @ApiOperation(value = "查询文件信息", notes = "查询文件信息List", httpMethod = "POST", response = Result.class)
    @RequestMapping(value = "/selectByMasterIdOrType", method = RequestMethod.POST)
    public Result selectByMasterIdOrType(@RequestBody @ApiParam(name = "fileManagement", value = "传入json格式") FileManagement fileManagement) {
        List<FileManagement> list = fileManagementService.selectByMasterIdOrType(fileManagement);
        return Result.success(list);
    }
}

